<%-- 
    Document   : changepass
    Created on : Nov 28, 2013, 8:11:34 PM
    Author     : Welcome
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link rel="stylesheet" href="css/bocuc.css" type="text/css"/>
        <link rel="stylesheet" href="css/style.css" type="text/css"/>

        <link rel="stylesheet" href="css/testcss.css" type="text/css"/>
        <link rel="stylesheet" href="css/mystyle.css" type="text/css"/>
        <link rel="stylesheet" href="css/botoncss.css" type="text/css"/>
        <script type="text/javascript" src="jquery/jquery-1.1.3.1.min.js"></script> 
        <script type="text/javascript" src="jquery/jquery-1.4.2.js"></script> 
        <script type="text/javascript" src="jquery/jquery-latest.js"></script>
        <script type="text/javascript" src="jquery/myjquery.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <title> Thay đổi mật khẩu</title>
        <script>
            var xmlhttp;
            function check()
            {
                xmlhttp = GetXmlHttpObject();

                if (xmlhttp == null)
                {
                    alert("Your browser does not support Ajax HTTP");
                    return;
                }
                    var pass = document.getElementById("txtOldPass").value;
                    var url = "checkpass.jsp";
                    url = url + "?pass=" + pass;

                    xmlhttp.onreadystatechange = getOutput;
                    xmlhttp.open("GET", url, true);
                    xmlhttp.send(null);
            }
             function getOutput()
            {
                if (xmlhttp.readyState == 4 || xmlHttp.readyState == "complete")
                {
                    document.getElementById("pass").innerHTML = xmlhttp.responseText;
                }
            }
            function GetXmlHttpObject()
            {
                if (window.XMLHttpRequest)
                {
                    return new XMLHttpRequest();
                }
                if (window.ActiveXObject)
                {
                    return new ActiveXObject("Microsoft.XMLHTTP");
                }
                return null;
            }
            function check_pass()
            {
                var pass = document.getElementById("txtPassword").value;
                var passc = document.getElementById("txtChkPassword").value;

                if (pass.trim() === "") {
                    document.getElementById("ck_pass").innerHTML = "<p style='color:red'>Mật khẩu không được bỏ trống!</p>";
                }
                else {
                    document.getElementById("ck_pass").innerHTML = "<p style='color:green'>Mật khẩu hợp lệ!</p>";
                }
                if (pass != passc)
                {
                    document.getElementById("idcheck_pass").innerHTML = "<p style='color:red'>Mật khẩu phải giống nhau</p>";
                    document.getElementById("txtChkPassword").value = "";
                }
                else if (passc.trim() === "") {
                    document.getElementById("idcheck_pass").innerHTML = "<p style='color:red'>Bạn phải nhập lại mật khẩu!</p>";
                    document.getElementById("txtChkPassword").value = "";
                }
                else {
                    document.getElementById("idcheck_pass").innerHTML = "<p style='color:green'>Mật khẩu hợp lệ!</p>";
                }
            }
        </script>
    </head>
    <body>
        <div class="bodypage">
            <!phan dau cua trang>
            <div class="top">
                <%@include file='header.jsp'%>
            </div>
            <!phan search>
            <div class="khoangcachtrang">
                <div class="searchgroup">

                    <%@include file='search.jsp' %> 
                    <div class="chontimkiem">
                        <a href="timkiemnangcao.jsp">Tìm Kiếm Nâng Cao</a>
                    </div>

                </div>
            </div>

            <!phan giua trang >
            <div class="centerpage">

                <div class="leftsite">
                    <div class="menuweb">
                        <%@include file='menuleft.jsp' %>
                    </div>
                </div>

                <div class="content">
                    <div class="khoangtrang"></div>
                    <h1>Thay đổi mật khẩu!</h1>
                    <form  class="thaymatkhau" action="RegisterController" method="post" id="formChange">
                        <input name="txtOldPass" id="txtOldPass" type="password" placeholder="Nhập mật khẩu cũ" onBlur="check();"/>
                        <div id="pass"></div>
                        <br>
                        <input name="txtNewPass" id="txtPassword" type="password" placeholder="Nhập mật khẩu mới"/>
                        <div id="ck_pass"></div><br>
                         <input name="txtOldPass" id="txtChkPassword"type="password" placeholder="Nhập lại mật khẩu mới" onBlur="check_pass();"/>
                         <div id="idcheck_pass"></div> <br>
                        <input value="ChangePass" name="action" type="submit"/>
                        <input value="Cancel" type="submit" id="closeChange" name="action"/>
                    </form>
                    <div class="khoangtrang"></div>
                </div>
                    

            </div>
            <!phan cuoi trang>
            <div class="footer">
                <div class="footerleft"></div>
                <div class="footerright"></div>
            </div>
        </div>

    </body>
</html>
